#include <OgreCamera.h>
#include "Camera.h"
#include "application.h"

OMGCamera::OMGCamera() : mTarget(0)
{
	mCameraNode = gSceneMgr->getRootSceneNode ()->createChildSceneNode ("Camera");
	mTargetNode = gSceneMgr->getRootSceneNode ()->createChildSceneNode ("Camera_Target");
	mCameraNode->setAutoTracking (true, mTargetNode);
	mCameraNode->setFixedYawAxis (true);
	mOgreCamera = gSceneMgr->createCamera("Camera");
	mOgreCamera->setPosition (0,0,0);
	//mOgreCamera->lookAt(0,0,0);
	mOgreCamera->setNearClipDistance(0.1);
	mCameraNode->attachObject (mOgreCamera);
}

void OMGCamera::update(float k, Ogre::Vector3 cameraPosition, Ogre::Vector3 targetPosition)
{
	distance = (cameraPosition - mCameraNode->getPosition ())*0.02;
	mCameraNode->translate (distance);
	distance = (targetPosition - mTargetNode->getPosition ())*0.02;
	mTargetNode->translate (distance);
}

/*OMGCamera::OMGCamera() : mTarget(0)
{
    mOgreCamera = gSceneMgr->createCamera("Camera");
    mOgreCamera->setPosition(0,5,5);
	mOgreCamera->lookAt(0,0,0);
    mOgreCamera->setNearClipDistance(1);
}

void OMGCamera::setTarget(Object* target)
{
	mTarget=target;
	mOgreCamera->setAutoTracking(true,mTarget->mNode);
	
}

void OMGCamera::update(float k)
{
	
}

void OMGCamera::setPosition(double x, double y, double z)
{
	mOgreCamera->setPosition(x,y,z);
}
*/